// 引入 react 依赖
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Text, View, Image, TouchableOpacity, ImageBackground, ScrollView, InteractionManager, TextInput } from 'react-native';

// 引入第三方依赖
import _ from 'lodash';
import pureRender from 'pure-render-decorator';
import Icon from 'react-native-vector-icons/dist/Ionicons';
import { Actions } from 'react-native-router-flux';

// antd 按需加载
import { Tabs, Toast } from '@ant-design/react-native';

// 引入 处理数据 所需文件
import { } from './module/module.js'

// 引入样式
import Style from './style/style.js';

// 引入公用组件
import { Status, NavBar } from '../../components/index.js'

// 引入专用组件
import { } from './components'

// 引入工具包
import { press, size, ScreenWidth } from '../../util/utils.js'
class Search extends Component {
  constructor(props) {
    super(props)
    this.state = {
      refreshing: false,
    }
  }

  componentDidMount() {
    const { } = this.props
    // InteractionManager.runAfterInteractions(() => {
    // ...耗时较长的同步执行的任务...
    // });
  }

  handleSearch() {
    Actions.goodsList({
      keyword: this.search._lastNativeText
    })
  }

  render() {
    return (
      <View style={Style.container}>
        <Status />
        <Status />
        <View style={{
          flexDirection: 'row',
          alignItems: 'center',
          justifyContent: 'space-between',
          backgroundColor: '#fff'
        }}>
          <TouchableOpacity
            style={{
              width: 44,
              height: 44,
              alignItems: 'center',
              justifyContent: 'center',
            }}
            onPress={() => {
              Actions.pop()
            }}
          >
            <Icon name="md-arrow-back" size={22} color="#252525" />
          </TouchableOpacity>
          <View
            style={{
              flex: 1,
              height: 30,
            }}
          >
            <View
              style={{
                paddingVertical: 0,
                paddingHorizontal: 15,
                borderRadius: 15,
                height: 30,
                backgroundColor: '#f7f7f7',
              }}
            >
              <TextInput
                ref={(r) => this.search = r}
                placeholder="请输入书籍名称"
                placeholderTextColor="#c8c8ca"
                style={{
                  fontSize: 16,
                  borderWidth: 0,
                  color: '#333',
                  lineHeight: 30,
                  padding: 0
                }}
                underlineColorAndroid="transparent"
              />
            </View>
          </View>
          <TouchableOpacity
            style={{
              width: 44,
              height: 44,
              alignItems: 'center',
              justifyContent: 'center',
            }}
            onPress={() => {
              this.handleSearch()
            }}
          >
            <Icon name="md-search" size={22} color="#252525" />
          </TouchableOpacity>
        </View>
      </View >
    );
  }
}


export default connect(({ user }) => ({
  user,
}))(pureRender(Search))
